import requests
from lxml import etree
# url='https://music.163.com/song?id=488249475'
url='https://img2.kuwo.cn/star/albumcover/500/50/74/2464786134.jpg'
head={
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36'
    ,'Accept': 'image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8',
    'Accept-Encoding': 'gzip, deflate, br',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Cache-Control': 'no-cache',
    'Connection': 'keep-alive',
    'Cookie': '_ga=GA1.2.1741002322.1650526536; Hm_lvt_cdb524f42f0ce19b169a8071123a4797=1653913952; _gid=GA1.2.1985476234.1653913952; Hm_lpvt_cdb524f42f0ce19b169a8071123a4797=1653915767',
    'Host': 'img2.kuwo.cn',
    'Pragma': 'no-cache',
    'Referer': 'https://www.kuwo.cn/',
    'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="102", "Google Chrome";v="102"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': 'Windows',
    'Sec-Fetch-Dest': 'image',
    'Sec-Fetch-Mode': 'no-cors',
    'Sec-Fetch-Site': 'same-site'}
# songname=[]
respone=requests.get(url,headers=head)
print(respone.content)
with open("./文件/"  + "图片歌曲.jpg", mode="wb") as f:
    f.write(respone.content)
# html=etree.HTML(respone.text)
# id_list=html.xpath('//img/@data-src')
# # 第一种方法
# print(id_list)
# id_list=html.xpath('//meta[16]/@content')
# # 第二种方法
# print(id_list)
